package org.kealinghornets.ak.al;

import android.app.Activity;
import android.app.Application;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }
     public void OnClick (View view){

             EditText edit_text_length= (EditText)findViewById(R.id.length);
             EditText edit_text_width =(EditText)findViewById(R.id.width);

             String string_length= edit_text_length.getText().toString();
             String string_width= edit_text_width.getText().toString();
        Double Length;

         if(string_length == null || string_length.isEmpty()) {

          Length = 0.0;

         } else {
             Length = Double.parseDouble(string_length);

         }
          Double width;
         if(string_width==null || string_width. isEmpty()) {
            width= 0.0;
         } else {
            width = Double.parseDouble(string_width);
         }

        double area= Length*width;
        String variable=area+ "";

        EditText answerBox=(EditText)findViewById(R.id.answerbox);
        answerBox.setText(variable);


     }
     public void asia (View view) {
         EditText asian= (EditText)findViewById(R.id.answerbox);
         ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
         ClipData clip = ClipData.newPlainText("label", asian.getText().toString());
         clipboard.setPrimaryClip(clip);

        Toast.makeText(getApplicationContext(),"copy",Toast.LENGTH_LONG).show();

     }
    private void getText(EditText input7) {
            }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }

}
